package com.alliky.classify.ui.viewmodel;

import android.graphics.drawable.Drawable;

import androidx.annotation.NonNull;
import androidx.core.content.ContextCompat;
import androidx.databinding.ObservableField;

import com.alliky.core.entity.vo.CategoryVO;
import com.alliky.core.base.ItemViewModel;
import com.alliky.classify.R;
import com.alliky.core.binding.command.BindingAction;
import com.alliky.core.binding.command.BindingCommand;

/**
 * @Description TODO
 * @Author wxianing
 * @Date 2020-11-15
 */
public class ClassifyItemLeftViewModel extends ItemViewModel<ClassifyViewModel> {

    public ObservableField<CategoryVO> entity = new ObservableField<>();
    public Drawable drawableImg;

    public ClassifyItemLeftViewModel(@NonNull ClassifyViewModel viewModel, CategoryVO entity) {
        super(viewModel);
        this.entity.set(entity);
        //ImageView的占位图片，可以解决RecyclerView中图片错误问题
        drawableImg = ContextCompat.getDrawable(viewModel.getApplication(), R.mipmap.ic_launcher);
    }

    //item点击事件
    public BindingCommand onItemClick = new BindingCommand(new BindingAction() {
        @Override
        public void call() {
            CategoryVO categoryVO = entity.get();
        }
    });
}
